using System;
using System.Collections.Generic;
using System.Text;

namespace GoogleNet
{
    /// <summary>
    /// A geographic location defined by longitude, latitude, and (optional) altitude. 
    /// When a Point is contained by a Placemark, the point itself determines the position 
    /// of the Placemark's name and icon. When a Point is extruded, it is connected to the 
    /// ground with a line. This "tether" uses the current LineStyle.
    /// </summary>
    public class KmlPoint : KmlGeometry, IKmlGeometry, IKmlElement
    {
        private string tagName = "Point";

        #region MyRegion
        /// <summary>
        /// Initializes a new instance of the <see cref="KmlPoint"/> class.
        /// </summary>
        public KmlPoint()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="KmlPoint"/> class.
        /// </summary>
        /// <param name="latitude">The latitude.</param>
        /// <param name="longitude">The longitude.</param>
        /// <param name="altitude">The altitude.</param>
        public KmlPoint(double latitude, double longitude, double altitude)
        {
            coordinates.Latitude = latitude;
            coordinates.Longitude = longitude;
            coordinates.Altitude = altitude;
        } 
        #endregion

        #region Coordinates
        private KmlPointCoordinates coordinates = new KmlPointCoordinates();

        /// <summary>
        /// Gets or sets the coordinates.
        /// </summary>
        /// <value>The coordinates.</value>
        public KmlPointCoordinates Coordinates
        {
            get { return coordinates; }
            set { coordinates = value; }
        } 
        #endregion
        
        #region IKmlElement Members

        /// <summary>
        /// Name of the KML tag for this specific element.
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        public string TagName
        {
            get { return tagName; }
        }

        /// <summary>
        /// Generates the KML for this element including its child elements.
        /// </summary>
        /// <param name="writer">The XML writer that will be used to generate the KML.</param>
        public new void GenerateKml(System.Xml.XmlTextWriter writer)
        {
            writer.WriteStartElement(tagName);
            writer.WriteElementString("coordinates", coordinates.ToString());
            base.GenerateKml(writer);
            writer.WriteFullEndElement();
        }

        #endregion
    }
}
